//
// Created by xili on 2024/8/5 22:56.
// Go big or go home.
//

using namespace std;

class Solution {
public:
    int tribonacci(int n) {
        if (n == 1 || n == 2) {
            return 1;
        }
        if (n == 0) {
            return 0;
        }
        int a = 0, b = 1, c = 1;
        int ans = a + b + c;
        for (int i = 3; i < n; i++) {
            a = b;
            b = c;
            c = ans;
            ans = a + b + c;
        }
        return ans;
    }
};